﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanmia.Core;
using Tanmia.Basis.Domain;

namespace Tanmia.Domain
{
    public class DiscriminatedItemDomain : BaseDomainObject<DiscriminatedItem>
    {
        public DiscriminatedItem GetDiscriminatedItem(Item item, Color color, Person manufacturer)
        {
            return repository.Gets(x => x.Item.ItemID == item.ItemID &&
                x.Color.ColorID == color.ColorID &&
                x.Manufacturer.PersonID == manufacturer.PersonID)
                .FirstOrDefault<DiscriminatedItem>();
        }

        public bool IsDiscriminatedItemExisting(Item item, Color color, Person manufacturer)
        {
            if (GetDiscriminatedItem(item, color, manufacturer) == null)
                return false;
            else
                return true;
        }
    }
}
